package com.qby.common.utils;

import org.apache.commons.lang.StringUtils;

/**
 * @describe: 数据隐藏工具类
 * @author: yang
 * @date: 2019/12/31 12:20
 */
public class DataHideUtil {
    /**
     * 隐藏用户姓名
     *
     * @param userName
     * @return
     */
    public static String hideUserName(String userName) {
        if (StringUtils.isEmpty(userName)) {
            return "";
        }
        String firstWord = userName.substring(0, 1);
        return firstWord + "**";
    }

    /**
     * 隐藏手机号
     *
     * @param phone
     * @return
     */
    public static String hidePhone(String phone) {
        if (StringUtils.isEmpty(phone)) {
            return "";
        }
        String firstThree = phone.substring(0, 3);
        String endFour = phone.substring(phone.length() - 4);
        return firstThree + "****" + endFour;
    }

    /**
     * 隐藏身份证号码
     *
     * @param idCard
     * @return
     */
    public static String hideIdCard(String idCard) {
        if (StringUtils.isEmpty(idCard)) {
            return "";
        }
        String firstNumber = idCard.substring(0, 3);
        String endNumber = idCard.substring(idCard.length() - 1);
        return firstNumber + "****************" + endNumber;
    }

   /* public static void main(String[] args) {
        String userName = "邱博洋";
        String phone = "18226655973";
        String idCard = "340111199003071896";

        System.out.println(hideUserName(userName));
        System.out.println(hidePhone(phone));
        System.out.println(hideIdCard(idCard));
    }*/
}
